package com.chen.springboot.controller.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chen.springboot.common.Result;
import com.chen.springboot.entity.UserAdvice;
import com.chen.springboot.service.CustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Chen
 * @Date: 2023/11/17  16:36
 */
@Api(tags = {"用户建议接口"})
@RestController
@RequestMapping("/customerServ")
public class CustomerController {

    @Autowired
    private CustomerService customerService;


    @ApiOperation("用户建议收集")
    @PostMapping("/dd")
    public Result<?> addAdvice(@RequestBody UserAdvice userAdvice){
        customerService.addAdvice(userAdvice);
        return Result.success();
    }
    @ApiOperation("获取建议")
    @GetMapping
    public Result<?> getAdvice(@RequestParam(defaultValue = "1") Integer pageNum,
                               @RequestParam(defaultValue = "10") Integer pageSize,
                               @RequestParam(defaultValue = "") String search){
        Page<UserAdvice> data=customerService.getAdvice(pageNum,pageSize,search);
        return Result.success(data);
    }
    @ApiOperation("删除建议")
    @DeleteMapping
    public Result<?> deleteAdvice(@RequestParam Integer id){
        customerService.deleteAdvice(id);
        return Result.success();
    }
}
